import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';

@Injectable()
export class AuthGuard implements CanActivate {
    constructor(
        private router: Router
    ) { }
    canActivate() {
        const token = window.localStorage.getItem("auth_token")
        if (!token) {
            this.router.navigate(['/sigin'])
            return false //如果为空不能继续导航
        }
        return true; //有权限则继续导航
    }
}